package com.dnjn.happiness.emo.domain.vo;

import com.dnjn.happiness.emo.domain.Risk;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;

@Accessors(chain = true)
@Data
public class RecordScore implements Serializable {
    private Long userId;

    private String rtype;
    private String label;
    private BigDecimal weight;

    private Integer gCount;
    private Integer nCount;

    private Long gScore;
    private Long nScore;

    private Integer tcount;
    private Long tscore;

    public static RecordScore create(Long userId, Risk risk) {
        return new RecordScore()
                .setUserId(userId)
                .resetRisk(risk)
                .setGScore(0L)
                .setNScore(0L)
                .setGCount(0)
                .setNCount(0)

                .resetTotal()
                ;
    }

    public RecordScore resetTotal() {
        setTcount(getGCount() + getNCount());
        setTscore(getGScore() + getNScore());
        return this;
    }

    public RecordScore resetRisk(Risk risk) {
        return setRtype(risk.getRtype())
                .setWeight(risk.getWeight())
                .setLabel(risk.getLabel());

    }
}
